﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NNPlayerMultiple : MonoBehaviour {

    public UILabel timeLable;
    public GameObject Btn5;
    public GameObject Btn10;
    public GameObject Btn15;
    public GameObject Btn20;
    public GameObject Btn25;
    private int Multiple;
    public List<GameObject> Covers;
    private void Awake()
    {
        UIEventListener.Get(Btn5).onClick = ButtonClick;
        UIEventListener.Get(Btn10).onClick = ButtonClick;
        UIEventListener.Get(Btn15).onClick = ButtonClick;
        UIEventListener.Get(Btn20).onClick = ButtonClick;
        UIEventListener.Get(Btn25).onClick = ButtonClick;
    }


    public float timeCount = 6f;
    private void Update()
    {
        timeCount -= Time.deltaTime;

        if (timeCount > 0)
        {
            int i = (int)timeCount;
            timeLable.text = i.ToString();
        }
        else if (timeCount < 0)
        {
            Destroy(gameObject);
        }
    }
   

    /// <summary>
    /// 控制能点击的倍数 --最大倍数
    /// </summary>
    public void ShowCanClick(int maxPlayerMmultiple)
    {
        for (int i = 0; i < maxPlayerMmultiple; i++)
        {
            
            Covers[i].SetActive(false);
        }
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "1")
        {
            Multiple = 1;
        }
        else if (button.name == "2")
        {
            Multiple = 2;
        }
        else if (button.name == "3")
        {
            Multiple = 3;
        }
        else if (button.name == "4")
        {
            Multiple = 4;
        }
        else if (button.name == "5")
        {
            Multiple = 5;
        }
        SendPlayerMultipleRequest();
    }

    void SendPlayerMultipleRequest()
    {
        NnPlayerMultipleRequest lg = new Pb.NnPlayerMultipleRequest {  Multiple=Multiple };
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendProtobuf1(lg, MsgId.NnPlayerMultipleRequest);
    }
}
